package cuit.game.entity;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import jakarta.persistence.*;

@Entity
@Table(name = "t_contest")
public class Contest extends BaseEntity {

    @Column(name = "content")
    private String content;
    @OneToMany(mappedBy = "contest", cascade = {CascadeType.ALL}, orphanRemoval = true)
    private List<Team> teams = new ArrayList<Team>();
    public Contest() {
    }
    
 // getter 和 setter 方法
    public List<Team> getTeams() {
        return teams;
    }
    public void setTeams(List<Team> teams) {
        if (teams == null || teams.isEmpty()) {
            this.teams = new ArrayList<>();
        } else if (this.teams == null || teams.size() != 0) {
            this.teams = new ArrayList<>();
            this.teams.addAll(teams);
        } else {
            this.teams.clear();
            this.teams.addAll(teams);
        }
    }
    @Override
	public long getId() {
		// TODO Auto-generated method stub
		return super.getId();
	}

	@Override
	public void setId(long id) {
		// TODO Auto-generated method stub
		super.setId(id);
	}

	public void setContent(String type) {
	this.content = type;
    }

    public String getContent() {
	return content;
    }

    @Override
	public Date getCreateTime() {
		// TODO Auto-generated method stub
		return super.getCreateTime();
	}
	@Override
	public void setCreateTime(Date createTime) {
		// TODO Auto-generated method stub
		super.setCreateTime(createTime);
	}

	@Override
	public String toString() {
		return "Contest [content=" + content + ", teams=" + teams + "]";
	}
	
}